package com.yjz.leetcode.有序列表反转;


public class Test {

    public Node reverse(Node prev, Node node) {
        if (node == null) {
            return prev;
        }
        Node next = node.next;
        node.next = prev;
        return reverse(node, next);
    }
    public static void main(String[] args) {
        Node node1 = new Node(1);
        Node node2 = new Node(2);
        Node node3 = new Node(3);
        Node node4 = new Node(4);

        node1.next = node2;

        node2.next = node3;
        node3.next = node4;
        System.out.println("反转前:" + node1);
        Test test = new Test();
        Node node = test.reverse(null, node1);
        System.out.println("反转后" + node);
    }


}
